home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / DHTML - Dynamic Content / random-iframe-content.izs < prev    next >
Text File  |  2005-09-01  |  3KB  |  96 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Random iframe content
  4. <!/TITLE>
  5.  
  6. <!BROWSER>FF1+ IE5+<!/BROWSER>
  7.  
  8. <!DESCRIPTION>This script randomly selects from a group of URLs and displays one of them inside an iframe. Since it's an iframe, the content can be anything and everything. Some ideas for using this script are:
  9.  
  10. Randomly rotate and display HTML banners 
  11. Display a "random joke" from a large archive without having to download everything 
  12. Serve up random content consisting of rich HTML 
  13. The script works in IE4+/NS6+, and simply displays nothing in all other browsers.
  14.  
  15. <!/DESCRIPTION> 
  16.  
  17. <!CATEGORY>dynamic content<!/CATEGORY>
  18.  
  19. <!SCRIPT>
  20. <!-- START OF SCRIPT -->
  21. <script language="JavaScript1.2">
  22.  
  23. //Random iframe content- ⌐ Dynamic Drive (www.dynamicdrive.com)
  24. //For full source code, and Terms Of use, visit http://dynamicdrive.com
  25. //This credit MUST stay intact for use
  26.  
  27. var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
  28. var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
  29.  
  30. //Specify IFRAME display attributes
  31. var iframeprops='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'
  32.  
  33. //Specify random URLs to display inside iframe
  34. var randomcontent=new Array()
  35. randomcontent[0]="random1.htm"
  36. randomcontent[1]="random2.htm"
  37. randomcontent[2]="random3.htm"
  38. randomcontent[3]="random4.htm"
  39.  
  40. //No need to edit after here
  41. if (ie||dom)
  42. document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
  43.  
  44. function random_iframe(){
  45. if (ie||dom){
  46. var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
  47. iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
  48. }
  49. }
  50.  
  51. window.onload=random_iframe
  52.  
  53. </script>
  54. <!-- END OF SCRIPT -->
  55. <!/SCRIPT>
  56.  
  57. <!PREVIEW>
  58. <!-- START OF SCRIPT -->
  59.  
  60. <script language="JavaScript1.2">
  61.  
  62. //Random iframe content- ⌐ Dynamic Drive (www.dynamicdrive.com)
  63. //For full source code, and Terms Of use, visit http://dynamicdrive.com
  64. //This credit MUST stay intact for use
  65.  
  66. var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
  67. var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
  68.  
  69. //Specify IFRAME display attributes
  70. var iframeprops='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'
  71.  
  72. //Specify random URLs to display inside iframe
  73. var randomcontent=new Array()
  74. randomcontent[0]="random1.htm"
  75. randomcontent[1]="random2.htm"
  76. randomcontent[2]="random3.htm"
  77. randomcontent[3]="random4.htm"
  78.  
  79. //No need to edit after here
  80. if (ie||dom)
  81. document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
  82.  
  83. function random_iframe(){
  84. if (ie||dom){
  85. var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
  86. iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
  87. }
  88. }
  89.  
  90. window.onload=random_iframe
  91.  
  92. </script>
  93. <!-- END OF SCRIPT -->
  94. <!/PREVIEW>
  95.  
  96. <!RELATED>NONE<!/RELATED>